//
//  RNCommunityCitiesModule.m
//  RNCommunity
//
//  Created by 朱吉峥 on 2020/2/25.
//  Copyright © 2020 朱吉峥. All rights reserved.
//

#import "RNCommunityCitiesModule.h"

@implementation RNCommunityCitiesModule

RCT_EXPORT_MODULE()

RCT_REMAP_METHOD(cities_shareAction, shareWithDict:(NSDictionary *)dict) {
    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"PYRNShareNotification" object:dict];
}

RCT_REMAP_METHOD(cities_commentAction, commentWithDict:(NSDictionary *)dict) {
    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"PYRNPushToNextControllerNotification" object:dict];
}

RCT_REMAP_METHOD(cities_moreAction, moreWithDict:(NSDictionary *)dict) {
    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"PYRNMoreNotification" object:dict];
}

RCT_REMAP_METHOD(cities_clickCellAction, clickCellWithDict:(NSDictionary *)dict) {
    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"PYRNPushToNextControllerNotification" object:dict];
}

RCT_REMAP_METHOD(cities_clickImgAction, clickImgWithDict:(NSDictionary *)dict imgs:(NSArray *)imgs radius:(CGFloat)radius idx:(NSInteger)idx) {
    dispatch_async_on_main_queue(^{
        if (!imgs) {
            return;
        }
        NSDictionary *userInfo = @{@"idx":@(idx), @"radius":@(radius), @"imgs":imgs};
        NSLog(@"userInfo = %@", userInfo);
        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"PYRNShowImgNotification" object:dict userInfo:userInfo];
    });
}

RCT_REMAP_METHOD(cities_clickTopAction, clickTopWithDict:(NSDictionary *)dict) {
    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"PYRNPushToNextControllerNotification" object:dict];
}

@end
